/*****************************************************************
**                                                             	**
**  Copyright (C) 2004 Amlogic,Inc.                            	**
**  All rights reserved                                        	**
**        Filename : Win15Pic.c /Project:AVOS		       **
**        Revision : 1.0                                       	**
**                                                             	**
*****************************************************************/
#ifdef ENABLE_NETWORK
#include "../menu.h"
#include "Win15PicEvent_net.h"
#include "./win/NetmenuSetupEvent.h"

INT32S Win15Pic_netMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type)
    {
        case WM_SHOWWINDOW:
        return Win15Pic_netOnShow(hwnd, lpParam) ;
    }
    return 0 ;
}
INT32S Win15PicBar_netMsgProc(PHWND hwnd, INT32U msg_type, INT32S lpParam)
{
    switch( msg_type){
        case WM_SHOWWINDOW:
            return Win15PicBar_netOnShow(hwnd, lpParam) ;
        case WM_KEYDOWN:
            return Win15PicBar_netOnKeyPress(hwnd, lpParam) ;
    }
    return 0 ;
}

void SetWin15Pic_netPalette(void)
{
    YUVENTRY mask_para[4] = {0,4095,4095,4095};
    AWSetAlphaMask(0,4, mask_para);
    YUVENTRY palette_para[16] = {0x8000 | 16392,0x8000 | 16216,0x8000 | 17880,0x8000 | 16392,16280,16184,16088,16040,16024,15880,15208,15720,15016,15064,15304,15144};
    AWSetPalette(0,16, palette_para);
    return ;
}

void SetWin15Pic_netPos(HWND* pControl, INT8U CurOsdSize)
{
    switch(CurOsdSize)
      {
    	 
        default:
            RECT NormalWindowRect = {0,0,720,576};
            pControl->winrect = NormalWindowRect;
            CREATEWINDOWPARAM NormalWindowPara = {1,{{0,0,720,576},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{0,0,0,0},SetWin15Pic_netPalette};
            AWSendMessage(pControl, WM_WINDOW_RESET_DRAW_AREA, (INT32S)&NormalWindowPara);
            break ;
      }
       
    //end of switch
    return;
}

HWND *CreateControlWin15Pic_net(HWND* pParent)
{
    HWND* pNewControl;
    CREATEWINDOWPARAM window_para = {1,{{0,0,720,576},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{PF_PALETTE_256,0,0,0},SetWin15Pic_netPalette};
    //Create Menu Window -- 1
    pNewControl = AWCreateWinControl("TWindow","Win15Pic_net",WS_OVERLAPPEDWINDOW,
		         0,0,720,576,NULL, (INT32S)&window_para,Win15Pic_netMsgProc) ;
    pNewControl->win_id = 0 ;
    return pNewControl;
}


void Set15PicBar_netPos(HWND* pControl, INT8U CurOsdSize)
{
    int iLoop;
            pControl->winrect.top = pControl->parent->winrect.top + 0;
            pControl->winrect.left = pControl->parent->winrect.left + 0;
            pControl->winrect.width = 720;
            pControl->winrect.height = 576;
            pControl->draw_info_num = 23;
            RECT StandardDrawRect[23] = {
            {pControl->winrect.left + 0,pControl->winrect.top + 0,0,0},
            {pControl->winrect.left + 7,pControl->winrect.top + 67,154,117},
            
            {pControl->winrect.left + 7,pControl->winrect.top + 67,154,117},
            {pControl->winrect.left + 165,pControl->winrect.top + 67,154,117},
            {pControl->winrect.left + 323,pControl->winrect.top + 67,154,117},
            {pControl->winrect.left + 481,pControl->winrect.top + 67,154,117},
            {pControl->winrect.left + 639,pControl->winrect.top + 67,154,117},
            
            {pControl->winrect.left + 7,pControl->winrect.top + 198,154,117},
            {pControl->winrect.left + 165,pControl->winrect.top + 198,154,117},
            {pControl->winrect.left + 323,pControl->winrect.top + 198,154,117},
            {pControl->winrect.left + 481,pControl->winrect.top + 198,154,117},
            {pControl->winrect.left + 639,pControl->winrect.top + 198,154,117},
            
            {pControl->winrect.left + 7,pControl->winrect.top + 329,154,117},
            {pControl->winrect.left + 165,pControl->winrect.top + 329,154,117},
            {pControl->winrect.left + 323,pControl->winrect.top + 329,154,117},                              
            {pControl->winrect.left + 481,pControl->winrect.top + 329,154,117},
            {pControl->winrect.left + 639,pControl->winrect.top + 329,154,117},
            
            {pControl->winrect.left + 634,pControl->winrect.top + 15,100,26},
            {pControl->winrect.left + 650,pControl->winrect.top + 15,100,26},
            
            {pControl->winrect.left + 100,pControl->winrect.top + 450,200,26},
            {pControl->winrect.left + 100,pControl->winrect.top + 450,200,26},
            
            {pControl->winrect.left + 500,pControl->winrect.top + 450,100,26},
            {pControl->winrect.left + 10,pControl->winrect.top + 5,83,59},
            };
            for(iLoop=0; iLoop < 23; iLoop++)
                memcpy(&(pControl->draw_info[iLoop]), &StandardDrawRect[iLoop], sizeof(RECT));

    return;
}

HWND *CreateControl15PicBar_net(HWND *pParent)
{
    //Create Control -- 15PicBar
    HWND *pNewControl = AWCreateWinControl("TControl","15PicBar_net",(WS_CHILDWINDOW | WS_CHILDWINDOW),
		         0,0,720,576,pParent,0,Win15PicBar_netMsgProc) ;
    pNewControl->win_id = 2 ;
    pNewControl->draw_info_num = 23;
    pNewControl->draw_info = (PDRAWINFO)AVMem_umalloc(sizeof(DRAWINFO) * pNewControl->draw_info_num) ;
    DRAWINFO DrawDatas[23] = {
        {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_FOCUS,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PIC_LOSE,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)ICON_PAGE_BACKROUNG,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_STRING_DATA},
        {0,0,0,0,(INT32U)ICON_PHOTO_INFO_BACKROUNG,DT_RLE_BMP_DATA},
        {0,0,0,0,(INT32U)0,DT_STRING_DATA},
        {0,0,0,0,(INT32U)0,DT_STRING_DATA},
        {0,0,0,0,(INT32U)ICON_PHOTO_TOP,DT_RLE_BMP_DATA}};
    memcpy(pNewControl->draw_info, DrawDatas, sizeof(DRAWINFO) * pNewControl->draw_info_num) ;

    return pNewControl;
}

HWND* CreateMenuWin15Pic_net(void)
{
    HWND *pNewControl ;
    TWINDOWS *pWin;
    HWND *pWin15Pic = CreateControlWin15Pic_net(NULL);
    SetWin15Pic_netPos(pWin15Pic,CurrentOsdSize);


    pNewControl= CreateControl15PicBar_net(pWin15Pic);
    Set15PicBar_netPos(pNewControl,CurrentOsdSize);

    pWin = (TWINDOWS *)pWin15Pic;
    pWin->pFocusControl = AWFindWinCtrlByName("15PicBar_net");
    return pWin15Pic;
}

void WinResetWin15Pic_netControlsPos(HWND *pControl, INT8U CurOsdSize)
{
    switch(pControl->win_id){
        case 0://Win15Pic
            SetWin15Pic_netPos(pControl,CurOsdSize) ;
            break ;
        case 2://15PicBar
            Set15PicBar_netPos(pControl,CurOsdSize) ;
            break ;
    }//end of switch
}
void WinResetWin15Pic_netPos(HWND *pControl, INT8U CurOsdSize)
{
    HWND *pChildControl;
    if(pControl == NULL)
        pControl = AWFindWinCtrlByName("Win15Pic_net");
    if(pControl == NULL) return ;

    WinResetWin15Pic_netControlsPos(pControl, CurOsdSize) ;
    pChildControl = pControl->children ;
    while(pChildControl != NULL){
    	WinResetWin15Pic_netPos(pChildControl, CurOsdSize) ;
    	pChildControl = pChildControl->siblings ;
	}
	return ;
}

#endif
